#include "ses_buzzer.h"

void buzzer_init() {
	//set pin change interval in OCR0B so that the pwm does not start yet
		OCR0B = 0x7F;
		OCR0A = 0xFF;

		//set TC0 to fast PWM with OCR0A as TOP and toggle pin on match with OCR0B
		TCCR0A = (1 << COM0B1) | (1 << WGM01) | (1 << WGM00);

		//set TC0 prescaler to clk/64 and set WGM02 for fast PWM with OCR0A as TOP
		TCCR0B = (1 << CS01) | (1 << CS00) | (1 << WGM02);

}

void start_buzz() {

	//set pin direction
	DDR(BUZZER_PORT) |= (1 << BUZZER_PIN);
}

void end_buzz() {

	DDR(BUZZER_PORT) &= ~(1 << BUZZER_PIN);
}
